package com.atguigu.acyjl;

import android.view.View;

import com.atguigu.acyjl.activity.MainActivity;

import java.util.ArrayList;
import java.util.List;

public class ShowExplanation {
    int count=0;
    static String baseStr = "";
    static List<String> listStr = new ArrayList<>(6);


    public void showExplanation(final int levelSettings,final int idiomID,final boolean... iswxR){
        MainActivity.mainActivity.btn16.setText("123");
        details(levelSettings,idiomID,iswxR);

        //dialog

        MainActivity.mainActivity.btn16.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Dialog dialog = new Dialog(MainActivity.mainActivity);
                dialog.setMessage(String.valueOf(listStr));
                dialog.show();
            }
        });
//以下注释部分 报错
//        MainActivity.mainActivity.win.btnAnswers.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Dialog dialog = new Dialog(Win.win);
//                dialog.setMessage(String.valueOf(listStr));
//                dialog.show();
//            }
//        });
    }

    public void details(int levelSettings,int idiomID,boolean... iswxR){
        if(levelSettings==4){
            if(iswxR[0] && iswxR[3] && count==0){//w1,w4
                strAttach(idiomID);
                count++;
            }else if(iswxR[5] && count==1) {
                strAttach(idiomID);
                count++;
            }else if(iswxR[2] && iswxR[1] && count==2){
                strAttach(idiomID);
                count++;
            }else if(iswxR[4] && count==3){
                strAttach(idiomID);
                count++;
            }
//            show();
        }
    }

    public void strAttach(int idiomID){
        baseStr = baseStr.concat("\n"+MainActivity.mainActivity.easyDao.getAllWords().get(idiomID).getEasyCY().
                concat(":"+MainActivity.mainActivity.easyDao.getAllWords().get(idiomID).getMeaning()));

        listStr.add("\n"+MainActivity.mainActivity.easyDao.getAllWords().get(idiomID).getEasyCY().
            concat(":"+MainActivity.mainActivity.easyDao.getAllWords().get(idiomID).getMeaning()));


    }


}

